package com.zhongbo.java.websocket.web.controler;

import com.zhongbo.java.websocket.model.ChatHistory;
import com.zhongbo.java.websocket.service.IChatHistoryService;
import com.zhongbo.java.websocket.vo.PageVo;
import com.zhongbo.java.websocket.vo.RestResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 说明：
 *
 * @author 钟波dellNotebook
 * @since 2025年03月20日 星期四 14:34:11
 */
@RestController
@RequestMapping("/history")
// @Api注解的内容写在tags属性里
@Api(tags = "聊天记录接口")
public class ChatHistoryController {

    @Autowired
    private IChatHistoryService chatHistoryService;

    @PostMapping("/add")
    @ApiOperation("添加消息记录接口")
    public RestResultVo<ChatHistory> add(@RequestBody ChatHistory chatHistory){
        ChatHistory add = chatHistoryService.add(chatHistory);
        return RestResultVo.ok(add);
    }

    @GetMapping("listHistory")
    @ApiOperation("查询消息历史接口")
    public RestResultVo<PageVo<ChatHistory>> listHistory(Integer page,Integer pageSize){
        PageVo<ChatHistory> chatHistoryPageVo = chatHistoryService.listChatHistory(page, pageSize);
        return  RestResultVo.ok(chatHistoryPageVo);
    }

}
